<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <style>
        ul{
            margin: 0;
            padding: 0;
        }
        li {
            border: 1px dashed #999;
            font-size: 12px;
            line-height: 35px;
            padding-left: 5;
            margin: 5px;
            list-style: none;
        }
        li:hover {
            background-color: #eaeaea;
            transition: all 0.8s ease;
        }

        .v-enter, .v-leave-to {
            opacity: 0.0;
            transform: translateY(80px);
        }

        .v-enter-active, .v-leave-active {
            transition: all 0.8s ease;
        }

        /* 平稳过滤 */
        .v-move{
            transition: all 0.8s ease;
        }
        /* 平稳过滤 */
        .v-leave-active{
            position: absolute;
        }
    </style>
</head>
<body>
    <div id="app">
        <div>
            <label>Id:</label>
            <input type="text" v-model="id">
            <label>Name:</label>
            <input type="text" v-model="name">
            <input type="button" value="添加" @click="add">
        </div>
            <!-- 在实现列表过滤动画，如果需要过滤元素，是通过 v-for循环的话，不能使用 transaction 元素-->
            <!-- 应用使用 transition-group 元素-->
            <!-- appear: 页面加载时，也要显示动画 -->
            <!-- tag: 可以指定包裹元素，现在指定为ul,所以在外层不用再写 ul 标签 -->
            <transition-group appear tag="ul">
                <li v-for="(item, i) in list" :key="item.id" @click="del(i)">
                    {{item.id}} --- {{item.name}}
                </li>
            </transition-group>
    </div>
    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                id:'',
                name:'',
                list: [
                    {id: 1, name:'赵高'},
                    {id: 2, name:'秦桧'},
                    {id: 3, name:'严嵩'},
                    {id: 4, name:'魏忠贤'}
                ]
            }, 
            methods: {
                add(){
                    this.list.push( {id:this.id, name:this.name} );
                    this.id = this.name = '';
                },
                del(i){
                    this.list.splice(i, 1);
                }
            }
        });
    </script>
</body>
</html>